/*
 * @Author: your name
 * @Date: 2020-01-14 22:55:59
 * @LastEditTime : 2020-01-14 22:56:52
 * @LastEditors  : Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /hdreoprt/src/config/routerConf/index.js
 */


//获取code
function getBaseInfos(appid,url){
    let url_code = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+"&redirect_uri="+url+"&response_type=code&scope=snsapi_base&state=1&connect_redirect=1#wechat_redirect";
     window.location.href = url_code;//打开这个链接，你的url后面就会跟上code的参数
}
    
// 路由默认配置，路由表并不从此注入
export const ROUTER_DEFAULT_CONFIG = {
    waitForData: true,
    transitionOnLoad: true,
    linkActiveClass:"active"
}

export function routerBeforeEachFunc(to,from,next){

    if(to.matched.some(record => record.meta.requireAuth)){
        if (localStorage.getItem("userId")) {  // 通过vuex state获取当前的用户是否注册
          next();
        }else {
          next({
            path: '/login',
            query: {redirect: to.fullPath}  // 将跳转的路由path作为参数，登录成功后跳转到该路由
          })
        }
        return;
    }
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next();
}

export function routerAfterFunc(){
    
}